<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>v-bind</title>
    <script src="node_modules/vue/dist/vue.js"></script>
    <style>
        div {
            width: 100px;
            height: 100px;
            color: white;
        }

        .red {
            background-color: red;
        }

        .blue {
            background-color: blue;
        }
    </style>
</head>
<body>
<div id="app">
    <button @click="color='red'">红色</button>
    <button @click="color='blue'">蓝色</button>
    <!--v-bind可以省略-->
    <!--<div v-bind:class="color">-->

    <div :class="color">
        点击按钮改变背景颜色
    </div>

    <hr/>
    <button @click="bool=!bool">切换</button>
    <!--class属性的特殊用法-->
    <div :class="{red:bool,blue:!bool}"></div>
</div>
<script type="text/javascript">
    var app = new Vue({
        el: "#app",
        data: {
            color: "red",
            bool: true
        }
    });
</script>
</body>
</html>